<template>
  <div>
    <div class="ele-page-header">
      <div class="ele-page-title">扣点配置</div>
      <div class="ele-page-desc"> 用于扣点配置。</div>
    </div>
    <div class="ele-body">
      <el-card shadow="never">
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          label-width="230px"
          style="margin: 10px auto"
        >
          <el-row>
            <el-col :sm="12">
              <el-form-item
                label="形象克隆线路一扣点:"
                prop="avatar_high_deduct"
              >
                <el-input v-model="form.avatar_high_deduct" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>

              <el-form-item
                label="形象克隆线路二扣点:"
                prop="avatar_high_deduct_two"
              >
                <el-input v-model="form.avatar_high_deduct_two" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>

              <el-form-item label="形象克隆线路三扣点:" prop="avatar_deduct">
                <el-input v-model="form.avatar_deduct" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>
              <el-form-item
                label="形象克隆线路四扣点:"
                prop="avatar_deduct_four"
              >
                <el-input v-model="form.avatar_deduct_four" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>
              <el-form-item
                label="声音克隆高保真扣点:"
                prop="voice_high_deduct"
              >
                <el-input v-model="form.voice_high_deduct" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>
              <el-form-item label="专业版声音克隆:" prop="xunfei_sound_train">
                <el-input v-model="form.xunfei_sound_train" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>
              <el-form-item label="声音克隆入门版版扣点:" prop="voice_deduct">
                <el-input v-model="form.voice_deduct" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>

              <el-form-item label="AI文案扣点:" prop="ai_create_deduct">
                <el-input v-model="form.ai_create_deduct" clearable>
                  <template slot="append">点<em>/</em>每条</template>
                </el-input>
              </el-form-item>
              <el-form-item label="AI标题扣点:" prop="ai_title_create_deduct">
                <el-input v-model="form.ai_title_create_deduct" clearable>
                  <template slot="append">点<em>/</em>每条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="发布抖音扣点:" prop="douyin_video">
                <el-input v-model="form.douyin_video" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>

              <el-form-item label="IP账号采集:" prop="douyin_homepage">
                <el-input v-model="form.douyin_homepage" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="文生图:" prop="wensheng_picture">
                <el-input v-model="form.wensheng_picture" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="老照片修复:" prop="old_image_repair">
                <el-input v-model="form.old_image_repair" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="图像融合:" prop="face_transplant">
                <el-input v-model="form.face_transplant" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>
              <el-form-item label="换装:" prop="img_replacement">
                <el-input v-model="form.img_replacement" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

                <el-form-item label="手持商品:" prop="handheld_product">
                <el-input v-model="form.handheld_product" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :sm="12">
              <el-form-item label="视频线路一创作扣点:" prop="video_deduct">
                <el-input v-model="form.video_deduct" clearable>
                  <template slot="append">点<em>/</em>秒</template>
                </el-input>
              </el-form-item>
              <el-form-item
                label="视频线路二创作扣点:"
                prop="woni_video_deduct"
              >
                <el-input v-model="form.woni_video_deduct" clearable>
                  <template slot="append">点<em>/</em>秒</template>
                </el-input>
              </el-form-item>
              <el-form-item label="视频线路三创作扣点:" prop="composite_deduct">
                <el-input v-model="form.composite_deduct" clearable>
                  <template slot="append">点<em>/</em>分钟</template>
                </el-input>
              </el-form-item>

              <el-form-item
                label="视频线路四创作扣点:"
                prop="composite_deduct_four"
              >
                <el-input v-model="form.composite_deduct_four" clearable>
                  <template slot="append">点<em>/</em>分钟</template>
                </el-input>
              </el-form-item>

              <el-form-item
                label="声音克隆高保真合成扣点:"
                prop="high_fidelity_sound"
              >
                <el-input v-model="form.high_fidelity_sound" clearable>
                  <template slot="append">点<em>/</em>100字</template>
                </el-input>
              </el-form-item>
              <el-form-item
                label="专业版声音合成:"
                prop="xunfei_sound_generate"
              >
                <el-input v-model="form.xunfei_sound_generate" clearable>
                  <template slot="append">点<em>/</em>100字</template>
                </el-input>
              </el-form-item>

              <el-form-item label="剪辑扣点:" prop="clip_price">
                <el-input v-model="form.clip_price" clearable>
                  <template slot="append">每条</template>
                </el-input>
              </el-form-item>
              <el-form-item
                label="ai视频提取文案扣点:"
                prop="ai_video_extraction"
              >
                <el-input v-model="form.ai_video_extraction" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>
              <el-form-item label="发布视频号扣点:" prop="shipinghao_video">
                <el-input v-model="form.shipinghao_video" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>
              <el-form-item label="发布小红书扣点:" prop="xiaohongshu_video">
                <el-input v-model="form.xiaohongshu_video" clearable>
                  <template slot="append">点<em>/</em>次</template>
                </el-input>
              </el-form-item>

              <el-form-item label="主页视频分析:" prop="douyin_homepage_video">
                <el-input v-model="form.douyin_homepage_video" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="换发:" prop="change_hair">
                <el-input v-model="form.change_hair" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="高清照片:" prop="high_definition_img">
                <el-input v-model="form.high_definition_img" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>

              <el-form-item label="图生视频:" prop="img_generate_video">
                <el-input v-model="form.img_generate_video" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>
              <el-form-item label="音频提取:" prop="separate_audio">
                <el-input v-model="form.separate_audio" clearable>
                  <template slot="append">点<em>/</em>条</template>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item>
            <el-button type="primary" :loading="loading" @click="submit">
              提交
            </el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>

<script>
import { save, query } from '@/api/system/config';

export default {
  name: 'SetTally',
  data() {
    return {
      host: window.location.protocol + '//' + location.host,
      count: 0,
      // 提交状态
      loading: false,
      disabled: false,
      // 表单数据
      form: {
        voice_deduct: '',
        voice_high_deduct: '',
        avatar_deduct: '',
        avatar_high_deduct: '',
        face_deduct: '',
        video_deduct: '',
        ai_create_deduct: '',
        photo_deduct: '',
        photo_high_deduct: '',
        composite_deduct: '',
        ai_title_create_deduct: '',
        one_way_name: '',
        two_way_name: '',
        three_way_name: ''
      },
      // 表单验证规则
      rules: {
        voice_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        voice_high_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        avatar_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        avatar_high_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        face_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        video_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        ai_create_deduct: [
          {
            required: true,
            message: '请输入字数',
            trigger: 'blur'
          }
        ],
        photo_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        photo_high_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ],
        composite_deduct: [
          {
            required: true,
            message: '请输入点数',
            trigger: 'blur'
          }
        ]
      },
      // 表格列配置
      columns: [
        {
          prop: 'sign',
          label: '签名',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'auditResult',
          label: '状态',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'auditResult'
        }
      ],
      // 表格选中数据
      selection: [],
      // 当前编辑数据
      current: null,
      // 是否显示编辑弹窗
      showEdit: false
    };
  },
  methods: {
    query() {
      query({ group: 'tally' })
        .then((data) => {
          if (data != null) {
            this.form = data;
            this.count = data?.count;
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    /* 提交 */
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true;
          save(this.form)
            .then((msg) => {
              this.loading = false;
              this.$message.success(msg);
              this.query();
            })
            .catch((e) => {
              this.loading = false;
              this.$message.error(e.message);
            });
        } else {
          return false;
        }
      });
    },
    copy_url(content) {
      if (window.clipboardData) {
        window.clipboardData.setData('text', content);
      } else {
        (function (content) {
          //oncopy 事件在用户拷贝元素上的内容时触发。
          document.oncopy = function (e) {
            e.clipboardData.setData('text', content);
            e.preventDefault(); //取消事件的默认动作
            document.oncopy = null;
          };
        })(content);
        document.execCommand('Copy');
      }
      this.$message.success('复制成功！');
    }
  },
  mounted() {
    this.query();
  }
};
</script>
<style>
.my_input {
  width: 400px;
}

.pay_header {
  margin-bottom: 30px;
  font-size: 17px;
}
</style>
